package com.woniuxy.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.woniuxy.entity.BeforeQueryData;
import com.woniuxy.entity.FinaFow;
import com.woniuxy.entity.FinaLedger;
import com.woniuxy.service.FinaLedgerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 台账记录表Controller
 */
@RestController
@RequestMapping("/finaLedger")
public class FinaLedgerController extends BaseController {

    @Autowired
    private FinaLedgerService finaLedgerService;


    /**
     * 初始化台账记录页面
     *
     * @return
     */
    @GetMapping("/listLedger/{type}")
    public TableDataInfo initFinaLedgerPage(@PathVariable String type) {
        startPage();
        List<FinaLedger> allFinaFow = finaLedgerService.initFinaLedgerPage(type);
        return getDataTable(allFinaFow);
    }


    /**
     * 本金放款动态多条件查询
     *
     * @param finaFow
     * @return
     */
    @PostMapping("/queryLedger")
    public TableDataInfo queryLedger(@RequestBody BeforeQueryData beforeQueryData) {
        startPage();
        if(beforeQueryData.getDates()!=null){
            if(beforeQueryData.getDates().length==0){
                beforeQueryData.setDates(null);
            }
        }
        List<FinaLedger> alls = finaLedgerService.queryLedger(beforeQueryData);
        return getDataTable(alls);
    }



}
